<?php
/**
 * Created by PhpStorm.
 * User: yeluojun
 * Date: 14-5-10
 * Time: 下午3:34
 */

include_once dirname(__FILE__) .'/../common/common.php';
include_once  dirname(__FILE__) .'/../common/dbConn.php';



function  selectRecord($arg_req){

    $res =  param_check($arg_req);
    if($res["status"]!=0){
        return MsgArray(false,$res["msg"],null,"error");
    }

    $user_id = $arg_req["user_id"];
    $sql = "select USER_ID,I_COMPANY,COMPANY_ADDRESS,IN_DATE,OUT_DATE,POSITION,AWARD from t_inauguration_record where USER_ID = $user_id";
    $db = connectDatabase();
    $rs_cursor = $db->query($sql);
    $rs_cursor->setFetchMode(PDO::FETCH_ASSOC);
    $rs = $rs_cursor->fetchAll();
    return  MsgArray(true,"操作成功",$rs,"success");
}


function param_check($arg_body){
    if(!array_key_exists("user_id",$arg_body)){
        return retMsg::ret(1,"user_id为空");
    }
    if(!is_numeric($arg_body["user_id"])){
        return retMsg::ret(1,"user_id错误");
    }
    return  retMsg::ret(0,"pass");
}


class retMsg{
    public static function ret($arg_status,$arg_msg){
        return array("status"=>$arg_status,"msg"=>$arg_msg);
    }
}